# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest
    steps:
    - name: executing remote ssh commands using password
      uses: appleboy/ssh-action@master
      with:
        host: ${{ secrets.HOST }}
        username: ${{ secrets.USERNAME }}
        key: ${{ secrets.PEM }}
        port: ${{ secrets.PORT }}
        script_stop: true
        script: |
          export DOMAIN=${{ secrets.HOST }}
          export UUID=${{ secrets.UUID }}
          export TROJAN_PASSWORD=${{ secrets.TROJAN_PASSWORD }}
          export V2RAY_PATH=${{ secrets.V2RAY_PATH }}
          cd ~/vps-init
          git fetch && git reset origin/master --hard
          bash start.sh
